<!DOCTYPE html>
<html>
<!--模板【阿文菌导航页web03】的基础上修改-->
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta name="renderer" content="webkit" />
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
    <link rel="shortcut icon" href="favicon.ico" />
    <link rel="stylesheet" type="text/css" href="css/style.css" />
    <script src="js/jquery.min.js"></script>
    <script src="js/font.js"></script>
    <script src="js/particles.min.js"></script>
    <link rel="stylesheet" type="text/css" href="custom/style.css" />
    <script src="custom/user.js"></script>
    <title>导航页</title>
</head>
<body>
    <div id="particles-js" style="position:absolute; top: 0; z-index: -1; width: 100%;height: 98%;">
        <canvas class="particles-js-canvas-el" width="1303" height="960" style="width: 100%; height: 100%;"></canvas>
    </div>
    <div id="wrap">
        <div id="top">
            <div id="logo">
                <p></p>
                <div class="type-js headline">
                    <h1 class="text-js">Welcome</h1>
                </div>
            </div>
            <div id="kg-btn" class="">
                <input class='tgl tgl-flip' id='qieh' type='checkbox' />
                <label class='tgl-btn' data-tg-off='内网' data-tg-on='外网' for='qieh'></label>
            </div>
            <div id="div_head" class="local">
            </div>
            <div id="search" class="search">
                <form action="https://www.baidu.com/s" class="g-ib searchForm" target="_blank">
                    <div class="g-ib textWrapper">
                        <input placeholder="" name="word" value="" class="textInput" type="text" autocomplete="off">
                        <input alog-action="search" class="submitInput" type="submit" value="百度一下">
                    </div>
                </form>
            </div>
        </div>
        <div id="main">
            <div id="mainContainer" class="app animated fadeInLeft">

            </div>
            <div style="clear: both;"></div>
        </div>
    </div>
    <div id="footer">
        <div class="footer-contents">
            <div class="links">
            </div>
        </div>
    </div>
</body>
<!--模板【阿文菌导航页web03】的基础上修改-->
<script>
<?php
require 'custom/IPv6PrefixMatcher.php';
function isIntranet($ip) {
    // 常见的内网IP段
    $intranetRanges =explode(",",$_COOKIE["ipv4"]) ;
    // print_r($intranetRanges);
    foreach ($intranetRanges as $range) {
        list($subnet, $netmask) = explode('/', $range);
        if ((ip2long($ip) & ~((1 << (32 - $netmask)) - 1)) === ip2long($subnet)) {
            return true;
        }
    }
    return false;
}
$userIp = $_SERVER['REMOTE_ADDR']; // 获取用户IP
echo "//当前访问ip=[$userIp]". PHP_EOL;

$isIpv6 = IPv6PrefixMatcher::match($userIp, $_COOKIE["ipv6Prefix"]);
echo "//ipv6匹配结果($isIpv6)". PHP_EOL;

if (isIntranet($userIp) || $isIpv6) { 
    echo "//访问者可能在内网". PHP_EOL;
} else {
    echo "//访问者可能在外网
    window.onload = function () {
        var task = $.Deferred();
        setTimeout(function(){ task.resolve() }, 100);
        task.done(function(){//必须使用定时器延时执行,否则该操作早于部分页面元素渲染导致仅有部分元素操作生效
            $('#qieh').click();
        });
    }". PHP_EOL;
}
?>
</script>
</html>